home *** CD-ROM | disk | FTP | other *** search
- /* What is this?
- Its a short utility that will comment a file with its own versionstring.
-
- Who needs this?
- Someone who uses some kind of directory utility which displays file
- comment but not version. You can select file, click v2c, rescan
- the directory and just read the comment.
-
- Why is this useful?
- Sometimes you get some kind of a short utility which you allready have
- but filesizes don't match. It's a short way to find out which one is newer.
-
- How do I use it?
- Usage: V1.0 "v2c <Filename>" (no wildcards)
-
- V1.1 "v2c <Filename> [DOT] [ERASE] [NONAME] [QUIET]" for V1.1
- Desc. of parameters:
- DOT: if no version string is found, a dot (.) will be put instead.
- ERASE: This option will erase last comment if there was any before.
- Otherwise the version will be inserted at the beginning. Try it
- NONAME: This option will erase filename from version string.
- example: file "v2c" Version: "$VER: v2c 1.0" comment: "1.0"
- QUIET: no text will be written to output()
-
- Bugs?
- Sometimes when wildcards are used nothing happens and
- ERROR_BUFFER_OVERFLOW (303) is written to output(). This happened a lot
- when ap_Buf in AnchorPath structure was set to 233 bytes and most of
- the times crashed Amiga when it was set to 1 byte. It is set to 488
- bytes in this compiled version and the problem didn't occur yet. If it
- does please do let me know and I will set it to a higher value.
-
- Legal stuff?
- Cardware !!! It's the same as shareware but if you use this utility
- regular you don't have to send me money but you should send me a
- postcard to the address below. If you decide to do so (what you should)
- please send me a postcard with a picture of the city you live in.
-
- This code is crap!
- It is my gift to you.
-
- This is just what I have been waiting for and I want to contact the
- author and congratulate him!
- Great! Glad that at least someone is happy. If you like this, use it
- or want a better version, write to me and I'll be happy to help you.
-
- My address is:
-
- Drago Fiser
- Plecnikova 5
- 62000 Maribor
- Slovenia, Europe
- Tel. +386 (0)62 31956
-
- E-mail: Drago.Fiser@uni-mb.si
-
-
- And remember to send me a postcard!
-
- */
-
- #include <proto/dos.h>
-
- static struct RDArgs *rdargs;
- static LONG args[5];
-
-
- void StrCa(char *str1, char *str2, char *str3)
- { int i,j;
-
- for (i=0;(i<79) && (str1[i]!='\0');i++) str3[i]=str1[i];
- for (j=0;(i<79) && (str2[j]!='\0');j++) str3[i++]=str2[j];
- str3[i]='\0';
- return;
- }
-
- int GetVersion(BPTR fil,char *filcomm)
- { char d, *versionstring="$VER: v2c 1.1 (20.12.1994) by Drago Fiser";
- int i=0;
- ULONG filelength, st;
-
- Seek(fil,0,OFFSET_END);
- filelength=Seek(fil,0,OFFSET_BEGINNING);
- for (st=0; st<filelength; st++) {
- if ((d= FGetC(fil)) ==versionstring[i]) {
- if ((++i)==5) { FGets(fil,filcomm,80); return(1); }
- } else i=0;
- }
- return(0);
- }
-
- void Cis(struct FileInfoBlock *fibb)
- { BPTR Fil;
- char filcomm[80],*verstr,*filename,*filecomment;
-
- filename= fibb->fib_FileName; filecomment= fibb->fib_Comment;
- if (!args[4]) Printf("%s",filename);
- if (Fil=Open(filename,MODE_OLDFILE))
- { if (GetVersion(Fil,filcomm))
- { for(verstr=filcomm;*verstr==' ';verstr++);
- if (args[3]<0)
- { int i; for(i=0; (filename[i] & 223)==(*verstr & 223);i++) verstr++;
- for(;*verstr==' ';verstr++);
- }
- if (!args[4]) Printf("\t\t%s\n",verstr);
- if (args[2]<0) SetComment(filename,verstr);
- else { char newcomm[80], newcom2[80];
- StrCa(verstr,";",newcom2);
- StrCa(newcom2,filecomment,newcomm);
- SetComment(filename,newcomm);
- }
- }
- else
- { if (!args[4]) PutStr("\t.\n");
- if (args[1]<0)
- { if (args[2]<0) SetComment(filename,".");
- else { char newcomm[80]; StrCa(".",filecomment,newcomm);
- SetComment(filename,newcomm);
- }
- }
- }
- Close(Fil);
- } else if (!args[4]) Printf("Couldn't open file %s\n",filename);
- }
-
-
- main(void)
- {
- LONG err;
- BPTR olddir;
- struct AnchorPath ap;
-
- if ((rdargs=ReadArgs("FILENAME/A,DOT/S,ERASE/S,NONAME/S,QUIET/S",args,NULL))==NULL)
- { if (!args[4]) PutStr("Bad arguments.\n"); }
- else
- { ap.ap_BreakBits=SIGBREAKF_CTRL_C;
- for (err= MatchFirst((char *)args[0],&ap); err!= ERROR_NO_MORE_ENTRIES; err= MatchNext(&ap))
- {
- if (err) if (!args[4]) Printf(" Error :%ld\tDirEntryType :%ld\ton file :%s\n",err,ap.ap_Info.fib_DirEntryType,ap.ap_Info.fib_FileName);
- if ((ap.ap_Info.fib_DirEntryType < 0) && (err==0))
- { olddir=CurrentDir(ap.ap_Current->an_Lock);
- Cis(&ap.ap_Info);
- CurrentDir(olddir);
- }
- }
- MatchEnd(&ap);
- }
- FreeArgs(rdargs);
- if (!args[4]) Printf("All done!\n");
- }
-